''' 考勤管理 '''
from ams import amsservice as db
from flask import Blueprint, jsonify, redirect, url_for, request
import logging, requests
import sys, traceback, os, re

logger = logging.getLogger('app')

ams = Blueprint("ams", __name__, url_prefix="/api")

'''考勤信息可视化 '''
#获取考勤统计数据
@ams.route('/getstatisticaldata',methods=['GET','POST'])
def getstatisticaldata():
    param = {}
    param['project'] = request.args.get('project')
    param['kinmuym'] = request.args.get('kinmuym')
    result = db.getstatisticaldata(param)
    return jsonify(result)

#获取考勤年月
@ams.route('/getkinmuym',methods=['GET','POST'])
def getkinmuym():
    param = {}
    param['project'] = request.args.get('project')
    result = db.getkinmuym(param)
    return jsonify(result)

#获取考勤项目
@ams.route('/getproject',methods=['GET','POST'])
def getproject():
    result = db.getproject()
    return jsonify(result)

#获取考勤统计数据
@ams.route('/getkinmuinfo',methods=['GET','POST'])
def getkinmuinfo():
    param = {}
    param['project'] = request.args.get('project')
    result = db.getkinmuinfo(param)
    return jsonify(result)

#获取工作人员考勤数据
@ams.route('/getkinmulist',methods=['GET','POST'])
def getkinmulist():
    param = {}
    param['kubun'] = request.args.get('kubun')
    result = db.getkinmulist(param)
    return jsonify(result)

#获取工作人员考勤数据csv导出
@ams.route('/getkinmucsv',methods=['GET','POST'])
def getkinmucsv():
    param = {}
    param['kubun'] = request.args.get('kubun')
    result = db.getkinmucsv(param)
    return jsonify(result)

#获取工作人员考勤信息csv导出(按年月导出)
@ams.route('/exportcsvformonth',methods=['GET','POST'])
def exportcsvformonth():
    param = {}
    param['key'] = request.args.get('key')
    result = db.exportcsvformonth(param)
    return jsonify(result)
